'''
 * @ author     ：廖传港
 * @ date       ：Created in 2020/12/4 18:30
 * @ description：
 * @ modified By：
 * @ ersion     : 
 * @File        : test2.py 
'''

"""
加载已经持久化的模型
"""
'''
import joblib
import numpy as np

dnn = joblib.load("linear.model")  # 加载模型


n = 20
A = np.random.randn(10, n, n)

B = np.zeros((10,))

for i in range(10):
    B[i] = i / 10

predictB = dnn.BatchPredict(A)

print("predictB=", predictB)
predictBB = np.array([np.argmax(one_hot) for one_hot in predictB])
print("predictBB=", predictBB)
realB = B
print("realB",realB)
realBB = np.array([np.argmax(one_hot) for one_hot in realB])
print("realBB", realBB)
from sklearn.metrics import accuracy_score

# accuracy_score(predictYY, realYY)

print("准确数=",accuracy_score(predictBB, realBB, normalize=False))
print("准确率=",accuracy_score(predictBB, realBB))
'''

import pickle
import numpy as np
from dl9 import DNN


fl = open('C:/Users/LCG/Desktop/Neural_networks/com/lcg/version8/picklemodel.pkl', 'rb')
dnn = pickle.load(fl)  # 模型载入
fl.close()
n = 20
A = np.random.randn(10, n, n)

B = np.zeros((10,))

for i in range(10):
    B[i] = i / 10

predictB = dnn.BatchPredict(A)

print("predictB=", predictB)
predictBB = np.array([np.argmax(one_hot) for one_hot in predictB])
print("predictBB=", predictBB)
realB = B
print("realB",realB)
realBB = np.array([np.argmax(one_hot) for one_hot in realB])
print("realBB", realBB)
from sklearn.metrics import accuracy_score

# accuracy_score(predictYY, realYY)

print("准确数=",accuracy_score(predictBB, realBB, normalize=False))
print("准确率=",accuracy_score(predictBB, realBB))